package test0ne;

import java.util.HashMap;
import java.util.Map;

public class 导数 {

    public static void main(String[] args) {
        String agent = "48252\t王子诚\n" +
                "166\t张宁水滴筹\n" +
                "133\t梁敬华\n" +
                "56367\t刘亚楠\n" +
                "20\t赵乐刚\n" +
                "66583\t张志伟\n" +
                "67081\t何仁辉\n" +
                "547\t段续\n" +
                "67346\t马心舒\n" +
                "67336\t郭春磊\n" +
                "67340\t李志红\n" +
                "67339\t崔苗\n" +
                "67323\t冯艳\n" +
                "100000144\t杨国莹\n" +
                "57537\t由兴朋\n" +
                "57543\t朱万春\n" +
                "58153\t高征\n" +
                "100000854\t韩琳\n" +
                "100000856\t高敏\n" +
                "100000853\t刘雪梅\n" +
                "100000855\t唐阳阳\n" +
                "100000852\t王美琪\n" +
                "56944\t郭非凡\n" +
                "53817\t赵博强\n" +
                "66851\t孙丽姣\n" +
                "67332\t魏佳慧\n" +
                "1581\t陈宇飞\n" +
                "100000269\t于洋\n" +
                "100000329\t于丽丽\n" +
                "100000147\t陈永强\n" +
                "100000145\t贾伟\n" +
                "100000270\t于新\n" +
                "100000112\t李萌萌\n" +
                "100000282\t高晓燕\n" +
                "100000283\t朱伟男\n" +
                "100000734\t陈加美\n" +
                "100000735\t王天宇\n" +
                "100000736\t苏亚拉其其格\n" +
                "100000737\t舒美灵\n" +
                "100000738\t任桂金\n" +
                "100000739\t赵苗苗\n" +
                "100000740\t孙鹏举\n" +
                "100000314\t李茹月\n" +
                "100000289\t孙振东\n" +
                "100000299\t聂秀开\n" +
                "100000349\t高伟\n" +
                "100000346\t郭晓艳\n" +
                "100000094\t高雪\n" +
                "100000263\t谭士诚\n" +
                "100000292\t邱雅萍\n" +
                "100000293\t邱亚楠\n" +
                "100000298\t吴美东\n" +
                "100000341\t王丽\n" +
                "100000391\t潘贺凤\n" +
                "100000376\t孙丽丽\n" +
                "100000281\t刘燕\n" +
                "100000271\t刘麟\n" +
                "100000374\t张秀莲\n" +
                "100000390\t周立娟\n" +
                "100000381\t鞠文超\n" +
                "100000309\t刘亚茹\n" +
                "100000793\t许丽丽\n" +
                "100000343\t于欢欢\n" +
                "100000337\t任艳艳\n" +
                "100000353\t潘雪芳\n" +
                "1656\t衡文凯\n" +
                "59746\t潘亭亭\n" +
                "1371\t王青梅\n" +
                "56680\t王健伦\n" +
                "67757\t陈洋\n" +
                "59338\t王新蕊\n" +
                "59743\t郭乐乐\n" +
                "64632\t李红霞\n" +
                "59636\t吴彦飞\n" +
                "65920\t杨熙\n" +
                "63961\t冯彦井\n" +
                "67977\t陶文强\n" +
                "55277\t严亮\n" +
                "57689\t周淑芹\n" +
                "55875\t朱吉岭\n" +
                "68362\t杨阳\n" +
                "68282\t张凯丽\n" +
                "64617\t刘莉\n" +
                "68359\t李晨昊\n" +
                "57683\t赵晓婷\n";
        Map<String, String> agentMap = new HashMap<>();
        String[] agentRows = agent.split("\n");
        for (int i = 0; i < agentRows.length; i++) {
            String[] agentCol = agentRows[i].split("\t");
            agentMap.put(agentCol[0], agentCol[1]);
        }


        String content = "48252\t6\t35403\n" +
                "20\t6\t86389\n" +
                "56367\t6\t49964\n" +
                "57683\t1\t60174\n" +
                "133\t6\t86387\n" +
                "166\t6\t42723\n" +
                "66583\t6\t40327\n" +
                "67081\t5\t37319\n" +
                "547\t1\t86386\n" +
                "67323\t6\t56422\n" +
                "67346\t1\t86386\n" +
                "67340\t1\t86386\n" +
                "67339\t1\t86386\n" +
                "67336\t1\t32436\n" +
                "100000144\t1\t86386\n" +
                "100000854\t1\t86386\n" +
                "100000852\t1\t86386\n" +
                "100000853\t1\t86386\n" +
                "100000855\t1\t86386\n" +
                "100000856\t1\t86386\n" +
                "58153\t2\t86386\n" +
                "57537\t1\t86386\n" +
                "57543\t1\t86386\n" +
                "67332\t6\t86386\n" +
                "66851\t1\t86386\n" +
                "53817\t1\t86386\n" +
                "56944\t1\t86386\n" +
                "1581\t6\t86386\n" +
                "100000739\t1\t86386\n" +
                "100000736\t1\t86386\n" +
                "100000737\t1\t86386\n" +
                "100000734\t1\t86386\n" +
                "100000349\t7\t86386\n" +
                "100000740\t7\t86386\n" +
                "100000391\t7\t86386\n" +
                "100000735\t1\t86386\n" +
                "100000793\t7\t86386\n" +
                "100000298\t1\t86386\n" +
                "100000738\t7\t86386\n" +
                "100000094\t7\t86386\n" +
                "100000112\t7\t86386\n" +
                "100000263\t7\t86386\n" +
                "100000281\t7\t86386\n" +
                "100000271\t1\t86386\n" +
                "100000270\t7\t86386\n" +
                "100000283\t7\t86386\n" +
                "100000282\t7\t86386\n" +
                "100000269\t1\t86386\n" +
                "100000329\t1\t86386\n" +
                "100000147\t7\t86386\n" +
                "100000289\t1\t86386\n" +
                "100000145\t7\t86386\n" +
                "100000309\t7\t86386\n" +
                "100000376\t7\t86386\n" +
                "100000314\t1\t86386\n" +
                "100000341\t1\t86386\n" +
                "100000299\t7\t86386\n" +
                "100000390\t7\t86386\n" +
                "100000293\t1\t86386\n" +
                "100000346\t1\t86386\n" +
                "100000374\t7\t86386\n" +
                "100000381\t1\t86386\n" +
                "100000292\t1\t86386\n" +
                "100000353\t1\t86386\n" +
                "100000337\t1\t86386\n" +
                "100000343\t2\t86386\n" +
                "1656\t6\t86386\n" +
                "68282\t1\t86386\n" +
                "56680\t1\t86385\n" +
                "67977\t7\t86385\n" +
                "55277\t1\t86385\n" +
                "59338\t1\t86385\n" +
                "68359\t1\t86385\n" +
                "64617\t1\t86385\n" +
                "65920\t1\t86385\n" +
                "57689\t1\t86385\n" +
                "68362\t2\t54814\n" +
                "67336\t7\t7\n" +
                "67336\t6\t63\n" +
                "67336\t0\t622\n" +
                "67336\t8\t14\n" +
                "67336\t0\t151\n" +
                "67336\t8\t72\n" +
                "67336\t0\t2066\n" +
                "48252\t6\t50985\n" +
                "67336\t8\t322\n" +
                "67336\t6\t2\n" +
                "67336\t0\t444\n" +
                "67336\t8\t48\n" +
                "67336\t0\t434\n" +
                "59743\t2\t49911\n" +
                "67336\t8\t267\n" +
                "67336\t9\t2025\n" +
                "67081\t0\t316\n" +
                "67081\t6\t323\n" +
                "67081\t5\t2\n" +
                "67081\t4\t39\n" +
                "67081\t3\t20\n" +
                "67081\t8\t218\n" +
                "67081\t9\t64\n" +
                "67081\t0\t7\n" +
                "67081\t6\t247\n" +
                "67081\t1\t1574\n" +
                "67336\t6\t163\n" +
                "67336\t9\t806\n" +
                "67336\t0\t991\n" +
                "67081\t7\t11\n" +
                "67081\t0\t164\n" +
                "67081\t1\t28757\n" +
                "66583\t0\t42\n" +
                "66583\t5\t67\n" +
                "66583\t4\t139\n" +
                "66583\t3\t60\n" +
                "66583\t8\t60\n" +
                "66583\t9\t196\n" +
                "66583\t0\t17\n" +
                "66583\t5\t29516\n" +
                "67336\t8\t199\n" +
                "67336\t0\t1691\n" +
                "166\t6\t10766\n" +
                "67336\t9\t445\n" +
                "67336\t0\t242\n" +
                "67336\t9\t149\n" +
                "67336\t0\t471\n" +
                "67336\t8\t87\n" +
                "67336\t0\t275\n" +
                "67336\t8\t96\n" +
                "67336\t0\t563\n" +
                "59636\t2\t13\n" +
                "59636\t1\t41706\n" +
                "67336\t9\t44\n" +
                "67336\t3\t343\n" +
                "67336\t1\t40827\n" +
                "64632\t2\t51\n" +
                "64632\t1\t38046\n" +
                "67757\t2\t37690\n" +
                "56367\t1\t355\n" +
                "56367\t7\t118\n" +
                "56367\t1\t913\n" +
                "63961\t2\t35500\n" +
                "56367\t7\t15884\n" +
                "55875\t2\t34665\n" +
                "59746\t2\t374\n" +
                "59746\t1\t33876\n" +
                "166\t6\t901\n" +
                "166\t3\t39\n" +
                "166\t4\t320\n" +
                "166\t5\t64\n" +
                "166\t4\t9\n" +
                "166\t3\t11\n" +
                "166\t8\t4\n" +
                "166\t9\t15\n" +
                "166\t3\t37\n" +
                "166\t6\t59\n" +
                "166\t5\t12840\n" +
                "1371\t2\t1464\n" +
                "67323\t0\t697\n" +
                "1371\t1\t3\n" +
                "1371\t7\t2504\n" +
                "67323\t1\t9636\n" +
                "1371\t1\t3\n" +
                "1371\t7\t56\n" +
                "1371\t1\t2\n" +
                "1371\t7\t135\n" +
                "1371\t1\t4\n" +
                "1371\t7\t56\n" +
                "1371\t1\t4\n" +
                "1371\t7\t57\n" +
                "1371\t1\t7\n" +
                "1371\t7\t158\n" +
                "1371\t1\t3\n" +
                "1371\t7\t16\n" +
                "1371\t1\t3\n" +
                "1371\t7\t216\n" +
                "1371\t1\t4\n" +
                "1371\t7\t3491\n" +
                "57683\t7\t42\n" +
                "57683\t1\t26172\n" +
                "1371\t1\t2\n" +
                "1371\t7\t2986\n" +
                "1371\t1\t19825\n" +
                "67323\t7\t57\n" +
                "67323\t6\t19571\n" +
                "56367\t1\t2946\n" +
                "166\t6\t18596\n" +
                "67081\t7\t23\n" +
                "67081\t0\t24\n" +
                "67081\t0\t739\n" +
                "67081\t1\t99\n" +
                "67081\t7\t5\n" +
                "67081\t0\t90\n" +
                "67081\t0\t3\n" +
                "67081\t6\t1\n" +
                "67081\t0\t4\n" +
                "67081\t0\t95\n" +
                "67081\t0\t2\n" +
                "67081\t6\t1\n" +
                "67081\t0\t6\n" +
                "67081\t0\t240\n" +
                "56367\t7\t16205\n" +
                "67081\t1\t10477\n" +
                "66583\t0\t10446\n" +
                "66583\t1\t64\n" +
                "67081\t7\t3\n" +
                "67081\t0\t48\n" +
                "67081\t1\t2684\n" +
                "66583\t7\t6\n" +
                "66583\t0\t2421\n" +
                "66583\t0\t244\n" +
                "66583\t1\t109\n" +
                "67081\t7\t8\n" +
                "67081\t0\t29\n" +
                "67081\t2\t23\n" +
                "67081\t0\t34\n" +
                "67081\t1\t413\n" +
                "66583\t7\t5\n" +
                "66583\t0\t391\n" +
                "66583\t7\t6\n" +
                "66583\t1\t2261\n" +
                "67081\t7\t4\n" +
                "67081\t0\t6\n" +
                "67081\t0\t2245\n";
        String[] rows =  content.split("\n");
        Map<String, Map<String, Integer>> data = new HashMap<>();
        for (int i = 0; i < rows.length; i++) {
            String[] columns = rows[i].split("\t");
            if(data.get(columns[0]) == null) {
                Map<String, Integer> map = new HashMap<>();
                map.put(AgentStatusEnum.of(Integer.parseInt(columns[1])).getContent(), Integer.valueOf(columns[2]));
                data.put(columns[0], map);
            }else {
                Map<String, Integer> map = data.get(columns[0]);
                if(map.get(AgentStatusEnum.of(Integer.parseInt(columns[1])).getContent()) == null) {
                    map.put(AgentStatusEnum.of(Integer.parseInt(columns[1])).getContent(), Integer.valueOf(columns[2]));
                }else {
                    int seconds =  map.get(AgentStatusEnum.of(Integer.parseInt(columns[1])).getContent());
                    map.put(AgentStatusEnum.of(Integer.parseInt(columns[1])).getContent(), seconds+Integer.parseInt(columns[2]));
                }
            }
        }

        for (Map.Entry<String, Map<String, Integer>> entry : data.entrySet()) {

            for (Map.Entry<String, Integer> innerEntry : entry.getValue().entrySet()) {
                System.out.print(agentMap.get(entry.getKey())+"\t");
                System.out.print(innerEntry.getKey()+"\t"+innerEntry.getValue()+"\n");
            }
        }


    }


    public static String secondToTime1(int second) {
        if(second == 0){
            return "0 s";
        }
        int hours = second / 3600;//转换小时数
        second = second % 3600;//剩余秒数
        int minutes = second / 60;//转换分钟
        second = second % 60;//剩余秒数
        if (0 < hours) {
            return String.format("%02d", hours) + ":" + String.format("%02d", minutes) + ":" + String.format("%02d", second);
        } else if (0 < minutes) {
            return  "00:"+String.format("%02d", minutes) + ":" + String.format("%02d", second);
        }else {
            return "00:00"+String.format("%02d", second)+"";
        }
    }
}
